package com.xin.data.simbapesa.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.xin.data.simbapesa.base.BaseBindingAdapter;
import com.xin.data.simbapesa.databinding.SimbaValueItemBinding;
import com.xin.data.simbapesa.obj.SimbaValueInfo;
import com.xin.data.simbapesa.utils.LogUtil;

import java.util.List;

public class ValueAdapter extends BaseBindingAdapter<SimbaValueItemBinding, SimbaValueInfo> {


    String data;

    public ValueAdapter(Context context, List<SimbaValueInfo> dataList) {
        super(context, dataList);
    }


    @Override
    protected SimbaValueItemBinding initViewBinding(LayoutInflater inflater, ViewGroup parent) {
        return SimbaValueItemBinding.inflate(inflater);
    }

    @Override
    protected void bindData(SimbaValueItemBinding binding, SimbaValueInfo item, int position) {
        binding.tvTitle.setText(item.getTitle());
        boolean isSelected = false;
        LogUtil.e("me", "ValueAdapter data->" + data);
        if (!TextUtils.isEmpty(data) && data.equals(item.getTitle())) {
            isSelected = true;
        }
        binding.tvTitleLayout.setSelected(false);
        if (isSelected) {
            binding.tvBox.setVisibility(View.VISIBLE);
            binding.tvTitle.setTextColor(Color.parseColor("#7D41FF"));
            binding.tvTitleLayout.setSelected(true);
        } else {
            binding.tvBox.setVisibility(View.GONE);
            binding.tvTitle.setTextColor(Color.parseColor("#666666"));
            binding.tvTitleLayout.setSelected(false);
        }
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

}